package com.company;

/**
 * @date : 2022-11-24 下午4:21
 * 泛型方法调用
 * 更好理解继承的含义
 * 继承了上层，就拥有了上层的方法
 * @see com.company.P031_PlainMethodCall
 */

public class P030_GenericMethodCall {

    public static void main(String[] args) {
        AppleServiceImpl appleService = new AppleServiceImpl();
        appleService.method();
        BananaServiceImpl bananaService = new BananaServiceImpl();
        bananaService.method();
    }

    public static class AppleServiceImpl extends AbstractFruitService<AppleServiceImpl> {
        public void method() {
            AppleServiceImpl appleService = new AppleServiceImpl();
            System.out.println(check(appleService));
        }

        @Override
        boolean verify(AppleServiceImpl o) {
            return false;
        }
    }

    public static class BananaServiceImpl extends AbstractFruitService<BananaServiceImpl> {
        public void method() {
            BananaServiceImpl bananaService = new BananaServiceImpl();
            System.out.println(check(bananaService));
        }

        @Override
        boolean verify(BananaServiceImpl o) {
            return true;
        }
    }

    public static abstract class AbstractFruitService<T> {
        public boolean check(T o) {
            return verify(o);
        }

        abstract boolean verify(T o);
    }


}
